<?php
namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Session;
class CommentController extends Controller{

	public $assign = [];
	public function comment(Request $request){   
		$content = $request->post('content');
    $news_id = $request->post('news_id');
		if(Session::has('login_homeuser')){
        	$res = Session::get('login_homeuser');
        	// $user_id = $res['id'];
        	$name = $res['name'];
   			}else{
        	echo "<script>alert('您未登录');window.location.href='/login';</script>";
    	}
    	$model_comments = new \App\Model\Comments();
    	$info = $model_comments->insertOne($news_id,$name,$content);
	}

  public function reply(Request $request){
        $content = $request->post('content');
        $news_id = $request->post('news_id');
        $comment_id = $request->post('id');
        if(Session::has('login_homeuser')){
            $res = Session::get('login_homeuser');
            $name = $res['name'];
        }else{
            echo "<script>alert('您未登录');window.location.href='/login';</script>";
        }

        // $model_comments = new \App\Model\Comments();
        // $res = $model_comments->getUserNameById($comment_id);
        // $user = $res['user_name'];
        // $this->assign['user']=$user;

        $model_comments = new \App\Model\Comments();
        $info = $model_comments->insertReplay($news_id,$name,$content,$comment_id);
        
   

    }
}














?>